package api_.collectionTest.genericstest;

import java.util.ArrayList;
import java.util.Collections;

class Student implements Comparable<Student>
{
    private String name;
    private int score;

    @Override
    public String toString()
    {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    public Student(String name, int score)
    {
        this.name = name;
        this.score = score;
    }

    @Override
    public int compareTo(Student o)
    {
        return this.score-o.score;
    }
}

public class SortTest
{
    public static void main(String[] args)
    {
        ArrayList<Student> arrayList = new ArrayList<>();
        arrayList.add(new Student("A",11));
        arrayList.add(new Student("B",121));
        arrayList.add(new Student("C",1));
        arrayList.add(new Student("D",511));
        Collections.sort(arrayList);
        System.out.println(arrayList);
    }
}
